/*************************************************************************
	> File Name: player.h
	> Author: ma6174
	> Mail: ma6174@163.com 
	> Created Time: 2021年12月01日 星期三 21时55分47秒
 ************************************************************************/

#include<iostream>
#include <string>

class Player
{
public:
	Player() = default;
	Player(std::string n) : name(n) {}

	virtual void attack() = 0;
	virtual void defense() = 0;

protected:
	std::string name;
};

class Forwards : public Player
{
public:
	using Player::Player;

	virtual void attack()
	{
		std::cout << "前锋 " << this->name << " 进攻!" << std::endl;
	}

	virtual void defense()
	{
		std::cout << "前锋 " << this->name << " 防守!" << std::endl;
	}
};

class Center : public Player
{
public:
	using Player::Player;

	virtual void attack()
	{
		std::cout << "中锋 " << this->name << " 进攻!" << std::endl;
	}

	virtual void defense()
	{
		std::cout << "中锋 " << this->name << " 防守!" << std::endl;
	}
};

class Guards : public Player
{
public:
	using Player::Player;

	virtual void attack()
	{
		std::cout << "后卫 " << this->name << " 进攻!" << std::endl;
	}

	virtual void defense()
	{
		std::cout << "后卫 " << this->name << " 防守!" << std::endl;
	}
};

//外籍球员
class ForeignCenter
{
public:
	ForeignCenter() = default;
	ForeignCenter(std::string n) : name(n) {}

	void setName(std::string n)
	{
		name = n;
	}

	std::string getName()
	{
		return name;
	}

	void jingong()
	{
		std::cout << "外籍中锋 " << this->name << " 进攻!" << std::endl;
	}

	void fangshou()
	{
		std::cout << "外籍中锋 " << this->name << " 防守!" << std::endl;
	}

private:
	std::string name;
};

//适配器
class Translator : public Player
{
public:
	Translator() = default;
	Translator(std::string n)
	{
		this->name = n;
		fc.setName(n);
	}

	virtual void attack()
	{
		fc.jingong();
	}

	virtual void defense()
	{
		fc.fangshou();
	}

private:
	ForeignCenter fc;
};
